// pages/assortment/assortment.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    swiperHeight: '',
    isChoose: false,
    items: [{
        id: '1',
        img: '../../images/donggong-15.png',
        value: '金龙鱼',
        checked: 'true'
      },
      {
        id: '2',
        img:'../../images/donggong-15.png',
        value: '红鱼'
      },
      {
        id: '3',
        img: '../../images/donggong-15.png',
        value: '金枪鱼'
      },
      {
        id: '4',
        img: '../../images/donggong-15.png',
        value: '骨鱼'
      },
      {
        id: '5',
        img: '../../images/donggong-15.png',
        value: '金枪鱼'
      },
      {
        id: '6',
        img: '../../images/donggong-15.png',
        value: '骨鱼'
      },
      {
        id: '7',
        img: '../../images/donggong-15.png',
        value: '金枪鱼'
      },
      {
        id: '8',
        img: '../../images/donggong-15.png',
        value: '骨鱼'
      },

    ],
    index: 1
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    // 页面初始化 options为页面跳转所带来的参数
    var that = this;
    wx.getSystemInfo({
      success: function(res) {
        that.setData({
          swiperHeight: res.windowHeight - 130
        });
      }
    })
  },
  chooseRadio: function(e) {
    var items = this.data.items;
    for (var i = 0; i < items.length; i++) {
      if (items[i].id == this.data.index) {
        for (var j = 0; j < items.length; j++) {
          if (items[j].checked && j != i) {
            items[j].checked = false;
          }
        }
        items[i].checked = !(items[i].checked);
      }
    }
    this.setData({
      items: items
    });
  },

  radioChange: function(e) {
    this.data.index = e.detail.value;
  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})